<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>全局方法 parseFloat() 将字符串转换为数字</title>
</head>

<body>
    <h1>JavaScript 全局方法</h1>
    <p>parseFloat() 方法把字符串转换为数字：</p>
    <p id="demo"></p>
    <script>
        document.getElementById("demo").innerHTML =
            parseFloat("10") + "<br>" +
            parseFloat("10.33") + "<br>" +
            parseFloat("10 6") + "<br>" +
            parseFloat("10 years") + "<br>" +
            parseFloat("years 10");
    </script>
</body>

</html>